<!DOCTYPE html>
<html>
<head>
    <title>添加药品--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 <meta http-equiv="content-type" content="multipart/form-data" charset="UTF-8">

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">
    $(function () {       
		$('#backid').click(function(){
				window.location.href="index.html";
		 });
    });
    </script>
</head>
<body>
<form  class="definewidth m20"  id="myForm" enctype="multipart/form-data" method="post" action="/drug/updateM">
<table class="table table-bordered table-hover definewidth m10">

    <tr>
        <td width="10%" class="tableleft">药品编号</td>
        <td><input type="text" name="drug_id" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">图片</td>
        <td><input type="file" name="file"  id="file" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">进价</td>
        <td><input type="text" name="drug_inPrice" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">售价</td>
        <td><input type="text" name="drug_outPrice" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">药品名称</td>
        <td><input type="text" name="drug_name" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">药品类型</td>
        <td><input type="radio" name="drug_type" value="处方" checked/>处方药&nbsp;&nbsp;&nbsp;
            <input type="radio" name="drug_type" value="中药"/>中药&nbsp;&nbsp;&nbsp;
            <input type="radio" name="drug_type" value="西药"/>西药&nbsp;&nbsp;&nbsp;
            <input type="radio" name="drug_type" value="非处方"/>非处方
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">简单描述</td>
        <td><input type="text" name="drug_simDesc" value=""/></td>
    </tr>

    <tr>
        <td width="10%" class="tableleft">保质期</td>
        <td><input type="date" name="drug_endDate" /></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">详细描述</td>
        <td><input name="drug_detaDesc"></input></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">生产厂商</td>
        <td><input name="drug_fatory"></input></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">服用说明</td>
        <td><input type="text" name="drug_direction" value=""/></td>
    </tr>
   
	<tr>
        <td width="10%" class="tableleft">备注</td>
        <td><textarea name="drug_remark"> </textarea></td>
	</tr>
    <tr>
        <td colspan="2">
			<center>
				<button   class="btn btn-primary" id="btnUpdate" type="button">保存</button> &nbsp;&nbsp;
                <button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
</body>
</html>
<script>
    String.prototype.GetValue= function(para) {
        let reg = new RegExp("(^|&)"+ para +"=([^&]*)(&|$)");
        let r = this.substr(this.indexOf("\?")+1).match(reg);
        if (r!=null) return unescape(r[2]); return null;
    }

    //时间戳转换为日期
    function times(timeS) {
        // 比如需要这样的格式 yyyy-MM-dd hh:mm:ss
        var date = new Date(timeS);
        Y = date.getFullYear() + '-';
        M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
        D = date.getDate()<10?'0'+date.getDate():date.getDate() + '  ';
        h = date.getHours()<10?'0'+date.getHours():date.getHours() + ':';
        m = date.getMinutes()<10? '0'+date.getMinutes() :date.getMinutes();

        return Y+M+D+" "+h+m;
    }

    $(function () {
        $("#btnUpdate").click(function () {

            $.ajax({
                type: "POST",//这里必须写POST
                url: "/drug/add",
                data: new FormData($("#myForm")[0]),
                dataType:'json',
                cache:false,
                processData:false,
                contentType:false,
                success: function(vo){
                    if(vo.code==200) {
                        alert("添加成功！");
                    }else{
                        alert("添加失败！"+vo.msg);
                    }
                }
            });
        });
    });
</script>